package com.yanqu.road.server.cmd.tradewar;

import com.yanqu.road.pb.cross.tradewar.CrossTradeWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.tradewar.CrossTradeWarMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_TRADE_WAR_WANTED_DETAIL, desc = "跨服商战通缉详单")
public class CrossTradeWarWantedDetailCmd extends CrossUnionCommand {
    private int activityId;
    private String wantedUid;
    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarWantedDetailReqMsg reqMsg = CrossTradeWarProto.CrossTradeWarWantedDetailReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        wantedUid = reqMsg.getWantedUid();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarWantedDetailRespMsg.Builder respMsg = CrossTradeWarMgr.getTradeWarWantedDetailRespMsg(activityId, wantedUid, userId, serverId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.U_CROSS_TRADE_WAR_WANTED_DETAIL, respMsg);
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
